package com.ts_xiaoa.ts_android_library.widget

import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.LayoutInflaterCompat
import androidx.databinding.ViewDataBinding
import com.ts_xiaoa.ts_android_library.R
import com.ts_xiaoa.ts_android_library.databinding.RvMyAdapterBinding
import com.ts_xiaoa.ts_glide.loadCenterCropImage
import com.ts_xiaoa.ts_recycler_view.BaseViewHolder
import com.ts_xiaoa.ts_recycler_view.adapter.RvSingleTypeAdapter

/**
 * create by ts_xiaoA on 2020-08-29 11:28
 * email：443502578@qq.com
 * desc：
 */
class MyAdapter : RvSingleTypeAdapter<String>() {
    override fun getLayoutResId(viewType: Int): Int {
        return R.layout.rv_my_adapter
    }

    @SuppressLint("SetTextI18n")
    override fun onBindItem(holder: BaseViewHolder, rootBinding: ViewDataBinding?, item: String) {

        val testImageUrl =
            "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=954496120,1621506021&fm=11&gp=0.jpg"
        val binding = rootBinding as RvMyAdapterBinding
        binding.ivCover.loadCenterCropImage(testImageUrl)
        binding.tvTitle.text = "this is a title"
        binding.tvContent.text = "this is a content"
    }

}